<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>欢迎页面</title>
  <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
</head>
<body>
<div id="name"></div>
<div id="number"></div>
<div id="gender"></div>
<div id="code"></div>
<div id="email"></div>


<button id="btn2">抢宿舍</button>

<div id="result"></div>
</body>

<script type="text/javascript">
  $(document).ready(function () {
    var token = localStorage.getItem("token")
    var mobile = localStorage.getItem("mobile")

    $.ajax({
      type: 'post',
      //url: 'http://dorm.zhangqx.com/getUserInfo',
      url: 'http://localhost:8091/getUserInfo',
      contentType: 'application/x-www-form-urlencoded',
      dataType: 'json',
      data: {
        token,
        mobile
      },
      success: function (data){
        console.log(data)
        if(data.status === 1){
          $("#name").text("姓名：" + data.data.name)
          $("#number").text("学号：" + data.data.number)
          if(data.data.gender === "0"){
            $("#gender").text("性别：男")
          }else{
            $("#gender").text("性别：女")
          }

          $("#code").text("认证码：" + data.data.code)
          $("#email").text("邮箱：" + data.data.email)

        }else{
          $("#userInfo").text(data.msg)
        }
      },
      error: function (){
        alert('参数错误')
      }
    })
  })

  // document.getElementById("btn1").onclick = function(){
  //   window.location.href="http://127.0.0.1:8091/bed"
  // }
  document.getElementById("btn2").onclick = function(){
    window.location.href="http://127.0.0.1:8091/ord"
  }

</script>
</html>